package com.sky.web.admin;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping(value = "/admin/shop")
public class ShopController {


    @Autowired
    private RedisTemplate redisTemplate;

    // 设置店铺状态
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable("status") Integer status) {
        log.info("设置店铺状态{status}",status);
        // 链式编程
        redisTemplate.opsForValue().set("SHOP_STATUS", status);
        return Result.success();
    }

    // 查询店铺状态
    @GetMapping("status")
    public Result findStatus(){
        log.info("查询店铺状态");
        return Result.success(redisTemplate.opsForValue().get("SHOP_STATUS"));
    }
}
